import javax.sql.rowset.serial.SerialStruct;

public class PromotionResult {
    private SalesPromotion promotionType = null;
    private Double savedAmount;

    public PromotionResult(double saveAmount, SalesPromotion salesPromotion) {
        this.savedAmount = saveAmount;
        this.promotionType = promotionType;
    }

    public static PromotionResult getBest(PromotionResult first, PromotionResult second) {
        return first.betterThan(second) ? first : second;
    }

    private boolean betterThan(PromotionResult another) {
        return savedAmount > another.savedAmount;
    }

    public Double getSavedAmount() {
        return savedAmount;
    }

    public String formatStatement() {
        return savedAmount == 0 ? "" : String.format("%s, saving %.0f yuan%s",
                promotionType.getPromotionTitle(),savedAmount,StatementGenerator.DIVIDE);
    }
}
